tissue png image histograms

opencv python doc link

In [1]:
import os
import cv2
import tensorflow as tf
%matplotlib inline
from matplotlib import pyplot as plt
In [4]:
input_dir = '/code/research/images/mcw_he_stylegan_fakes'
In [5]:
def display_histogram_and_image(subdir, dirs, file):
    img = cv2.imread(os.path.join(subdir, file))
        
    fig, ax = plt.subplots(1,2, figsize=(20,10))
        
    ax[0].imshow(img)
    
    color = ('b','g','r')
    for i,col in enumerate(color):
        histr = cv2.calcHist([img],[i],None,[256],[0,256])
        ax[1].plot(histr,color = col)
        
    plt.title(file)
    plt.show()
In [7]:
def walk_through_dir_and_print_histograms(directory,max_plots=2):
    count = 0
    for subdir, dirs, files in os.walk(directory):
        for file in files:
            filepath = os.path.join(subdir, file)
            file_name, file_extension = os.path.splitext(file)
            if file_extension == '.png':
                display_histogram_and_image(subdir, dirs, file)
                count += 1
                if count == max_plots:
                    return 0

mcw stylegan fake generated images

1024 x 1024 pngs

In [8]:
walk_through_dir_and_print_histograms(input_dir, max_plots=25)

peso input dataset pngs

1024 x 1024 pngs

In [9]:
input_dir = '/code/research/images/peso_input_images'
In [10]:
walk_through_dir_and_print_histograms(input_dir, max_plots=25)